import { View } from "../../../mvc/core/View";
import { LayerManager } from "../../manager/LayerManager";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { EventName } from "../../mvc/EventName";
import { MsgManager } from "../../manager/MsgManager";
import { Language } from "../../../../extend/language/Language";
import { EPrictUnit } from "../../../../Message/Public/EPrictUnit";
import { Cache } from "../../cache/Cache";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { MarketOneConfig } from "../../resource/MarketOneConfig";
import { GTextFormat } from "../../../common/GTextFormat";
import { ECareer } from "../../../../Message/Public/ECareer";
import { BaseItem } from "../common/BaseItem";
import { DragEvent } from "../../../../com/mui/events/DragEvent";
import { MoneySelectPanel } from "./MoneySelectPanel";
import { SearchStringList } from "./SearchStringList";
import { MarketTwoConfig } from "../../resource/MarketTwoConfig";
import { ItemConfig } from "../../resource/ItemConfig";
import { ECategory } from "../../../../Message/Public/ECategory";
import { EColor } from "../../../../Message/Public/EColor";
import { DataEvent } from "../../events/DataEvent";
import { EBind } from "../../../../Message/Public/EBind";
import { ItemData } from "../../resource/info/ItemData";
import { ItemInfo } from "../../resource/info/ItemInfo";
import { SeekBuyItemInfo } from "./SeekBuyItemInfo";
import { Alert } from "../../../../com/mui/controls/Alert";
import { SearchConditionData } from "./SearchConditionData";
import { EMarketOrder } from "../../../../Message/Game/EMarketOrder";
import { EMarketRecordType } from "../../../../Message/Game/EMarketRecordType";
import { SSeqMarketItem } from "../../../../Message/Game/SSeqMarketItem";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { GComboBox } from "../../../../com/mui/controls/GComboBox";
import { GTextInput } from "../../../../com/mui/controls/GTextInput";
import { GNumericStepper } from "../../../../com/mui/controls/GNumericStepper";
import { GCheckBox } from "../../../../com/mui/controls/GCheckBox";
import { _ECareerWarrior } from "../../../../ECareer/_ECareerWarrior";
import { _ECareerArcher } from "../../../../ECareer/_ECareerArcher";
import { _ECareerFireMage } from "../../../../ECareer/_ECareerFireMage";
import { _ECareerDoctor } from "../../../../ECareer/_ECareerDoctor";
import { _ECareerWarriorD } from "../../../../ECareer/_ECareerWarriorD";
import { _ECareerStabber } from "../../../../ECareer/_ECareerStabber";
import { _ECareerIceMage } from "../../../../ECareer/_ECareerIceMage";
import { _ECareerPriest } from "../../../../ECareer/_ECareerPriest";
type int = number;
//class SeekBuyGoodsPanel
    
    export  class SeekBuyGoodsPanel extends View
    {
        constructor()
        {
            super();
            this._careerMap = new Map<any, any> /* flash.utils.Dictionary */();
            this._allCodesArr = [];
            this._itemArr = [];
            _layer = LayerManager.windowLayer;
            this.init();
            Dispatcher.addEventListener(EventName.MarketSeekBuyItemCode, this.onSeekBuyItemCodeHandler);
            Dispatcher.addEventListener(EventName.MarketSearchItemSelect, this.onSearchItemSelectHandler);
            return;
        }

        /* internal  */filterItemsByCareer(arg1: Array<any>): Array<any>
        {
            var loc3=null;
            var loc1=this._careerComBo.selectedItem.id;
            var loc2=[];
            var loc4=0;
            var loc5=arg1;
            for(loc3 of loc5) 
            {
                if (!(loc3.item.career & loc1)) 
                {
                    continue;
                }
                loc2.push(loc3);
            }
            return loc2;
        }

        /* internal  */updatePrice(): void
        {
            if (this._baseItem.itemData == null) 
            {
                MsgManager.showRollTipsMsg(Language.getString(31103));
                return;
            }
            this._rate = 0;
            var loc1=this._numStepper.value;
            var loc2=parseInt(this._unitPriceInput.text) * loc1;
            var loc3=this._unit;
            switch (loc3) 
            {
                case EPrictUnit._EPriceUnitCoin:
                {
                    this._rate = loc2;
                    this._coinBg.visible = true;
                    this._goldBg.visible = false;
                    break;
                }
                case EPrictUnit._EPriceUnitGold:
                {
                    this._rate = loc2 * 1000;
                    this._coinBg.visible = false;
                    this._goldBg.visible = true;
                    break;
                }
            }
            if (this._rate == 0) 
            {
                this._coinBg.visible = false;
                this._goldBg.visible = false;
                this._priceTxt.text = "";
                this._rateTxt.text = "";
            }
            else 
            {
                loc3 = this._time;
                switch (loc3) 
                {
                    case 8:
                    {
                        this._rate = Math.ceil(this._rate * 0.02);
                        break;
                    }
                    case 24:
                    {
                        this._rate = Math.ceil(this._rate * 0.03);
                        break;
                    }
                    case 48:
                    {
                        this._rate = Math.ceil(this._rate * 0.05);
                        break;
                    }
                }
                if (this._rate < 500) 
                {
                    this._rate = 500;
                }
                this._priceTxt.text = loc2 + "";
                this._rateTxt.text = Language.getString(31104) + this._rate + Language.getString(31105);
            }
            return;
        }

        /* internal  */init(): void
        {
            var loc4=null;
            var loc5=null;
            var loc6=null;
            var loc7=null;
            var loc8=null;
            var loc10=null;
            var loc11=null;
            this._selfCareer = Cache.instance.role.entityInfo.career;
            var loc1=ObjCreate.createBg(0, 0, 287, 298, this);
            ObjCreate.createBg(15, 35, 250, 2, this, ImagesConst.SplitLine);
            ObjCreate.createBg(15, 195, 250, 2, this, ImagesConst.SplitLine);
            ObjCreate.createBg(3, 7, 100, 21, this, ImagesConst.FightingStrgBg);
            ObjCreate.createTextField(Language.getString(31113), 10, 8, 200, 20, this, GlobalStyle.textFormat1);
            ObjCreate.createTextField(Language.getString(31090), 5, 45, 40, 20, this, GlobalStyle.textFormat2);
            ObjCreate.createTextField(Language.getString(31091), 5, 75, 40, 20, this, GlobalStyle.textFormat2);
            ObjCreate.createTextField(Language.getString(31092), 5, 105, 40, 20, this, GlobalStyle.textFormat2);
            ObjCreate.createTextField(Language.getString(31093), 5, 135, 40, 20, this, GlobalStyle.textFormat2);
            ObjCreate.createTextField(Language.getString(31094), 5, 165, 40, 20, this, GlobalStyle.textFormat2);
            this._nameTxtInput = ObjCreate.createGTextInput(100, 8, 140, 22, this);
            this._nameTxtInput.text = Language.getString(31027);
            this._nameTxtInput.addEventListener(flash.events.Event.CHANGE, this.onNameTxtInputChangeHandler);
            this._nameTxtInput.addEventListener(flash.events.FocusEvent.FOCUS_IN, this.onNameInputFocusInHandler);
            this._nameTxtInput.addEventListener(flash.events.FocusEvent.FOCUS_OUT, this.onNameInputFocusOutHandler);
            var loc2=new DataProvider();
            var loc3=MarketOneConfig.instance.firstSeekBuyInfoTagMap;
            var loc12=0;
            var loc13=loc3;
            for(loc4 of loc13) 
            {
                loc2.addItem({"id": loc4.oneId, "label": loc4.oneName});
            }
            this._categoryComBo = ObjCreate.createGComboBox(45, 45, 120, 22, loc2, this, "GComboboxSimple");
            this._categoryComBo.textField.setStyle("textFormat", new GTextFormat("", 12, 11661311, false, false, false, "", "", flash.text.TextFormatAlign.CENTER));
            this._categoryComBo.addEventListener(flash.events.Event.CHANGE, this.onCateGoryComBoChangeHandler);
            this._typeComBo = ObjCreate.createGComboBox(45, 75, 120, 22, null, this, "GComboboxSimple");
            this._typeComBo.textField.setStyle("textFormat", new GTextFormat("", 12, 11661311, false, false, false, "", "", flash.text.TextFormatAlign.CENTER));
            this._typeComBo.addEventListener(flash.events.Event.CHANGE, this.onTypeComBoChangeHandler);
            (loc5 = new DataProvider()).addItem({"id": 0, "label": Language.getString(31029), "index": 0});
            loc5.addItem({"id": 1, "label": Language.getString(31030), "index": 1});
            loc5.addItem({"id": 2, "label": Language.getString(31031), "index": 2});
            loc5.addItem({"id": 3, "label": Language.getString(31032), "index": 3});
            loc5.addItem({"id": 4, "label": Language.getString(31033), "index": 4});
            loc5.addItem({"id": 5, "label": Language.getString(31034), "index": 5});
            this._colorComBo = ObjCreate.createGComboBox(45, 105, 120, 22, loc5, this, "GComboboxSimple");
            this._colorComBo.textField.setStyle("textFormat", new GTextFormat("", 12, 11661311, false, false, false, "", "", flash.text.TextFormatAlign.CENTER));
            this._colorComBo.addEventListener(flash.events.Event.CHANGE, this.onColorComBoChangeHandler);
            this._careerMap[0] = {"id": 0, "label": Language.getString(31022), "index": 0};
            this._careerMap[ECareer._ECareerWarrior] = {"id": _ECareerWarrior, "label": Language.getString(31023), "index": 1};
            this._careerMap[ECareer._ECareerArcher] = {"id": _ECareerArcher, "label": Language.getString(31024), "index": 2};
            this._careerMap[ECareer._ECareerFireMage] = {"id": _ECareerFireMage, "label": Language.getString(31025), "index": 3};
            this._careerMap[ECareer._ECareerDoctor] = {"id": _ECareerDoctor, "label": Language.getString(31026), "index": 4};
            this._careerMap[ECareer._ECareerWarriorD] = {"id": _ECareerWarriorD, "label": Language.getString(31069), "index": 5};
            this._careerMap[ECareer._ECareerStabber] = {"id": _ECareerStabber, "label": Language.getString(31070), "index": 6};
            this._careerMap[ECareer._ECareerIceMage] = {"id": _ECareerIceMage, "label": Language.getString(31071), "index": 7};
            this._careerMap[ECareer._ECareerPriest] = {"id": _ECareerPriest, "label": Language.getString(31072), "index": 8};
            (loc6 = new DataProvider()).addItem(this._careerMap[0]);
            loc6.addItem(this._careerMap[ECareer._ECareerWarrior]);
            loc6.addItem(this._careerMap[ECareer._ECareerArcher]);
            loc6.addItem(this._careerMap[ECareer._ECareerFireMage]);
            loc6.addItem(this._careerMap[ECareer._ECareerDoctor]);
            loc6.addItem(this._careerMap[ECareer._ECareerWarriorD]);
            loc6.addItem(this._careerMap[ECareer._ECareerStabber]);
            loc6.addItem(this._careerMap[ECareer._ECareerIceMage]);
            loc6.addItem(this._careerMap[ECareer._ECareerPriest]);
            this._careerComBo = ObjCreate.createGComboBox(45, 135, 120, 22, loc6, this, "GComboboxSimple");
            this._careerComBo.textField.setStyle("disabledTextFormat", new GTextFormat("", 12, 10066329, false, false, false, "", "", flash.text.TextFormatAlign.CENTER));
            this._careerComBo.textField.setStyle("textFormat", new GTextFormat("", 12, 11661311, false, false, false, "", "", flash.text.TextFormatAlign.CENTER));
            this._careerComBo.addEventListener(flash.events.Event.CHANGE, this.onCareerComBoChangeHandler);
            (loc7 = new DataProvider()).addItem({"id": 0, "low": 1, "upper": 100, "label": Language.getString(31014), "index": 0});
            loc7.addItem({"id": 1, "low": 1, "upper": 9, "label": Language.getString(31015), "index": 1});
            loc7.addItem({"id": 10, "low": 10, "upper": 19, "label": Language.getString(31016), "index": 2});
            loc7.addItem({"id": 20, "low": 20, "upper": 29, "label": Language.getString(31017), "index": 3});
            loc7.addItem({"id": 30, "low": 30, "upper": 39, "label": Language.getString(31018), "index": 4});
            loc7.addItem({"id": 40, "low": 40, "upper": 49, "label": Language.getString(31019), "index": 5});
            loc7.addItem({"id": 50, "low": 50, "upper": 59, "label": Language.getString(31020), "index": 6});
            loc7.addItem({"id": 60, "low": 60, "upper": 100, "label": Language.getString(31021), "index": 7});
            this._levelComBo = ObjCreate.createGComboBox(45, 165, 120, 22, loc7, this, "GComboboxSimple");
            this._levelComBo.textField.setStyle("textFormat", new GTextFormat("", 12, 11661311, false, false, false, "", "", flash.text.TextFormatAlign.CENTER));
            this._levelComBo.addEventListener(flash.events.Event.CHANGE, this.onLevelComBoChangeHandler);
            this.onCateGoryComBoChangeHandler();
            ObjCreate.createTextField(Language.getString(31114), 195, 45, 80, 20, this, GlobalStyle.textFormat6);
            ObjCreate.createBitmap(ImagesConst.PackItemBg, 200, 70, this);
            this._baseItem = new BaseItem();
            this._baseItem.x = 203;
            this._baseItem.y = 73;
            this._baseItem.setSize(33, 33);
            addChild(this._baseItem);
            this._baseItem.addEventListener(DragEvent.Event_Move_In, this.onItemMoveInHandler);
            this._baseItem.addEventListener(DragEvent.Event_Throw_goods, this.onItemThrowGoodsHandler);
            this._baseItem.addEventListener(flash.events.MouseEvent.CLICK, this.onItemClickHandler);
            ObjCreate.createGTextField(Language.getString(31096), 175, 115, 120, 20, this, GlobalStyle.textFormat5);
            loc8 = new GTextFormat("", 12, 268419072);
            this._maxPriceTxt = ObjCreate.createTextField("", 200, 140, 150, 20, this, loc8);
            this._maxPriceImg = new Object /* flash.display.Bitmap */();
            this._maxPriceImg.x = 180;
            this._maxPriceImg.y = 142;
            addChild(this._maxPriceImg);
            ObjCreate.createTextField(Language.getString(31097), 5, 210, 80, 20, this, GlobalStyle.textFormat2);
            ObjCreate.createTextField(Language.getString(31098), 5, 245, 80, 20, this, GlobalStyle.textFormat2);
            ObjCreate.createTextField(Language.getString(31099), 145, 245, 80, 20, this, GlobalStyle.textFormat2);
            ObjCreate.createTextField(Language.getString(31100), 5, 273, 80, 20, this, GlobalStyle.textFormat2);
            this._unitPriceInput = ObjCreate.createGTextInput(70, 210, 100, 22, this);
            this._unitPriceInput.restrict = "0-9";
            this._unitPriceInput.maxChars = 8;
            this._unitPriceInput.addEventListener(flash.events.Event.CHANGE, this.onUnitPriceChangeHandler);
            this._moneySelect = new MoneySelectPanel();
            this._moneySelect.x = 185;
            this._moneySelect.y = 195;
            addChild(this._moneySelect);
            this._moneySelect.addEventListener(EventName.MarketMoneyTypeChange, this.onMoneyTypeChangeHandler);
            this._numStepper = ObjCreate.createGNumericStepper(70, 245, 55, 22, this);
            this._numStepper.addEventListener(flash.events.Event.CHANGE, this.onNumStepperChangeHandler);
            var loc9;
            (loc9 = new DataProvider()).addItem({"id": 8, "label": Language.getString(31056), "index": 0});
            loc9.addItem({"id": 24, "label": Language.getString(31057), "index": 1});
            loc9.addItem({"id": 48, "label": Language.getString(31058), "index": 2});
            this._timeCombo = ObjCreate.createGComboBox(205, 245, 70, 22, loc9, this);
            this._timeCombo.addEventListener(flash.events.Event.CHANGE, this.onTimeComboChangeHandler);
            this._goldBg = ObjCreate.createBitmap(ImagesConst.Yuanbao_small, 70, 275, this);
            this._goldBg.visible = false;
            this._coinBg = ObjCreate.createBitmap(ImagesConst.Tongqian_small, 70, 275, this);
            this._coinBg.visible = false;
            this._priceTxt = ObjCreate.createTextField("", 90, 273, 180, 20, this, loc8);
            this._rateTxt = ObjCreate.createTextField("", 150, 273, 100, 20, this, loc8);
            this._broadcastCb = ObjCreate.createCheckBox(Language.getString(31123), 5, 295, 200, 40, this);
            (loc10 = ObjCreate.createGButton(Language.getString(31101), 130, 303, 60, 25, this)).addEventListener(flash.events.MouseEvent.CLICK, this.onSubmitBtnClickHandler);
            (loc11 = ObjCreate.createGButton(Language.getString(31088), 200, 303, 60, 25, this)).addEventListener(flash.events.MouseEvent.CLICK, this.onResetBtnClickHandler);
            this._stringList = new SearchStringList();
            this._stringList.x = 100;
            this._stringList.y = 30;
            return;
        }

        /* internal  */onCateGoryComBoChangeHandler(arg1: Object /* flash.events.Event */=null): void
        {
            var loc5=null;
            var loc6=0;
            var loc7=0;
            this._selfCareer = Cache.instance.role.entityInfo.career;
            var loc1=this._categoryComBo.selectedItem.id;
            var loc2=[];
            var loc3=new DataProvider();
            var loc4=MarketTwoConfig.instance.getMarketSeekSubTagsByOneid(loc1);
            var loc8=0;
            var loc9=loc4;
            for(loc5 of loc9) 
            {
                loc2.push({"id": loc5.twoIndex, "label": loc5.twoName, "career": loc5.career});
            }
            loc2.sortOn("id", Array.NUMERIC);
            loc6 = 0;
            loc7 = 0;
            while (loc7 < loc2.length) 
            {
                loc3.addItem(loc2[loc7]);
                if (loc2[loc7].career & this._selfCareer && !(loc2[loc7].career == -1) && !(loc2[loc7].career == 0)) 
                {
                    loc6 = loc7;
                }
                ++loc7;
            }
            this._typeComBo.dataProvider = loc3;
            this._typeComBo.selectedIndex = loc6;
            this.updateSeekBuyItemPanel();
            return;
        }

        /* internal  */onTypeComBoChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            this.updateSeekBuyItemPanel();
            return;
        }

        /* internal  */updateSeekBuyItemPanel(): void
        {
            var loc4=null;
            var loc5=0;
            this._selfCareer = Cache.instance.role.entityInfo.career;
            var loc1=this._categoryComBo.selectedItem.id;
            var loc2=this._typeComBo.selectedItem.id;
            var loc3=this._typeComBo.selectedItem.career;
            this.getAllCodes();
            if (this._careerComBo) 
            {
                loc5 = 0;
                if (loc1 == 11) 
                {
                    var loc6=0;
                    var loc7=this._careerMap;
                    for(loc4 of loc7) 
                    {
                        if (!(loc4.id & loc3)) 
                        {
                            continue;
                        }
                        loc5 = loc4.index;
                        break;
                    }
                }
                else if (loc4 = this._careerMap[this._selfCareer]) 
                {
                    loc5 = loc4.index;
                }
                this._careerComBo.selectedIndex = loc5;
            }
            if (this._colorComBo) 
            {
                this._colorComBo.selectedIndex = 0;
            }
            if (this._levelComBo) 
            {
                this._levelComBo.selectedIndex = 0;
            }
            this.updateSeekBuyItem();
            return;
        }

        /* internal  */getAllCodes(): void
        {
            var loc5=null;
            var loc7=0;
            var loc8=0;
            var loc1=this._categoryComBo.selectedItem.id;
            var loc2=this._typeComBo.selectedItem.id;
            var loc3=this._typeComBo.selectedItem.career;
            var loc4=Cache.instance.market.getCodesInMarket(loc1, loc2, loc3);
            this._allCodesArr.splice(0);
            var loc6=[];
            var loc9=0;
            var loc10=loc4;
            for(loc7 of loc10) 
            {
                if (!(loc5 = ItemConfig.instance.getInfoByCode(loc7))) 
                {
                    continue;
                }
                if (!(!(loc5.item.category == ECategory._ECategoryEquip) || loc5.item.category == ECategory._ECategoryEquip && loc5.item.color >= EColor._EColorBlue && loc5.item.level >= 30 && loc5.item.level <= 70 && loc5.item.level % 10 == 0)) 
                {
                    continue;
                }
                loc6.push({"color": loc5.item.color, "career": loc5.item.career, "level": loc5.item.level, "itemInfo": loc5});
            }
            loc6.sortOn(["color", "career", "level"], [Array.NUMERIC, Array.NUMERIC, Array.NUMERIC]);
            loc8 = 0;
            while (loc8 < loc6.length) 
            {
                this._allCodesArr.push(loc6[loc8].itemInfo);
                ++loc8;
            }
            return;
        }

        /* internal  */onColorComBoChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            this.updateSeekBuyItem();
            return;
        }

        /* internal  */onCareerComBoChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            var loc2=0;
            var loc3=null;
            var loc4=0;
            var loc5=0;
            var loc1=this._categoryComBo.selectedItem.id;
            if (loc1 == 11) 
            {
                loc2 = this._careerComBo.selectedItem.id;
                loc5 = 0;
                while (loc5 < 4) 
                {
                    if ((loc3 = this._typeComBo.getItemAt(loc5)) && loc3.career & loc2) 
                    {
                        loc4 = loc5;
                        break;
                    }
                    ++loc5;
                }
                this._typeComBo.selectedIndex = loc4;
                this._typeComBo.drawNow();
            }
            this.getAllCodes();
            this.updateSeekBuyItem();
            return;
        }

        /* internal  */onLevelComBoChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            this.updateSeekBuyItem();
            return;
        }

        /* internal  */updateSeekBuyItem(): void
        {
            var loc5=null;
            var loc1=this._categoryComBo.selectedItem.id - 10;
            var loc2=this._colorComBo.selectedItem.id;
            var loc3=this._careerComBo.selectedItem.id;
            var loc4;
            if ((loc4 = this._typeComBo.selectedItem.career) == -1) 
            {
                loc3 = 0;
            }
            var loc6=[];
            if (loc3 == 0) 
            {
                var loc7=0;
                var loc8=this._allCodesArr;
                for(loc5 of loc8) 
                {
                    loc6.push(loc5);
                }
            }
            else 
            {
                loc6 = this.filterItemsByCareer(this._allCodesArr);
            }
            if (loc2 != 0) 
            {
                loc6 = this.filterItemsByColor(loc6);
            }
            if (loc1 <= 3) 
            {
                loc6 = this.filterItemsByLevel(loc6);
            }
            dispatchEvent(new DataEvent(EventName.MarketFilterItemsResult, loc6));
            return;
        }

        /* internal  */filterItemsByColor(arg1: Array<any>): Array<any>
        {
            var loc3=null;
            var loc1=this._colorComBo.selectedItem.id;
            var loc2=[];
            var loc4=0;
            var loc5=arg1;
            for(loc3 of loc5) 
            {
                if (loc3.item.color != loc1) 
                {
                    continue;
                }
                loc2.push(loc3);
            }
            return loc2;
        }

        /* internal  */filterItemsByLevel(arg1: Array<any>): Array<any>
        {
            var loc3=0;
            var loc5=null;
            var loc1=this._levelComBo.selectedItem.low;
            var loc2=this._levelComBo.selectedItem.upper;
            var loc4=[];
            var loc6=0;
            var loc7=arg1;
            for(loc5 of loc7) 
            {
                if (!((loc3 = loc5.item.level) >= loc1 && loc3 <= loc2)) 
                {
                    continue;
                }
                loc4.push(loc5);
            }
            return loc4;
        }

        /* internal  */onItemMoveInHandler(arg1: DragEvent): void
        {
            this.reset();
            var loc1=arg1.dragItem as BaseItem;
            if (loc1 && loc1.itemData && loc1.itemData.bind == EBind._EBindYes) 
            {
                this._code = loc1.itemData.itemInfo.item.codeUnbind;
            }
            else if (loc1 && loc1.itemData) 
            {
                this._code = loc1.itemData.itemCode;
            }
            if (this._code <= 0) 
            {
                MsgManager.showRollTipsMsg(Language.getString(31102));
                return;
            }
            this._baseItem.itemData = new ItemData(this._code);
            this.searchMaxPrice();
            return;
        }

        public onItemThrowGoodsHandler(arg1: DragEvent): void
        {
            this.reset();
            return;
        }

        public onItemClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.reset();
            return;
        }

        /* internal  */onNameTxtInputChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            var loc2=null;
            var loc3=null;
            var loc1=this._nameTxtInput.text;
            if (loc1 == Language.getString(31027)) 
            {
                return;
            }
            if (loc1.length >= 2) 
            {
                this._itemArr.splice(0);
                this._itemArr = Cache.instance.market.getCodesByString(loc1);
                if (this._itemArr.length <= 0) 
                {
                    if (this._stringList.parent) 
                    {
                        removeChild(this._stringList);
                    }
                    return;
                }
                this._stringList.updateDataProvider(this._itemArr);
                addChild(this._stringList);
                if (this._itemArr.length == 1) 
                {
                    loc2 = new Map<any, any> /* flash.utils.Dictionary */();
                    loc3 = this._itemArr[0].itemInfo as ItemInfo;
                    this._code = loc3.item.code;
                    if (loc1 == loc3.item.name) 
                    {
                        if (this._stringList.parent) 
                        {
                            removeChild(this._stringList);
                        }
                    }
                    this.onSearchBtnClickHandler();
                }
            }
            else if (this._stringList.parent) 
            {
                removeChild(this._stringList);
            }
            return;
        }

        /* internal  */onNameInputFocusInHandler(arg1: Object /* flash.events.FocusEvent */): void
        {
            if (!(this._nameTxtInput.text == "") && this._nameTxtInput.text == Language.getString(31027)) 
            {
                this._nameTxtInput.text = "";
                if (this._stringList.parent) 
                {
                    removeChild(this._stringList);
                }
            }
            return;
        }

        /* internal  */onNameInputFocusOutHandler(arg1: Object /* flash.events.FocusEvent */): void
        {
            if (this._nameTxtInput.text == "") 
            {
                this._nameTxtInput.text = Language.getString(31027);
            }
            return;
        }

        /* internal  */onSearchItemSelectHandler(arg1: DataEvent): void
        {
            var loc1=null;
            var loc2=null;
            if (this._stringList && this._stringList.parent) 
            {
                removeChild(this._stringList);
                loc1 = arg1.data as ItemInfo;
                loc2 = loc1.item.name;
                this._nameTxtInput.text = loc2;
                this._code = loc1.item.code;
                this.onSearchBtnClickHandler();
            }
            return;
        }

        /* internal  */onSearchBtnClickHandler(arg1: Object /* flash.events.MouseEvent */=null): void
        {
            if (this._code == 0) 
            {
                return;
            }
            this._baseItem.itemData = new ItemData(this._code);
            this.searchMaxPrice();
            return;
        }

        /* internal  */onUnitPriceChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            this.updatePrice();
            return;
        }

        /* internal  */onNumStepperChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            this.updatePrice();
            return;
        }

        /* internal  */onMoneyTypeChangeHandler(arg1: DataEvent): void
        {
            this._unit = arg1.data as int;
            this.updatePrice();
            return;
        }

        /* internal  */onTimeComboChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            this._time = this._timeCombo.selectedItem.id;
            this.updatePrice();
            return;
        }

        /* internal  */onResetBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.reset();
            return;
        }

        public reset(): void
        {
            this._moneySelect.resetSelecter();
            this._baseItem.itemData = null;
            this._unitPriceInput.text = "";
            this._numStepper.value = 1;
            this._timeCombo.selectedIndex = 0;
            this._nameTxtInput.text = Language.getString(31027);
            this._priceTxt.text = "";
            this._rateTxt.text = "";
            this._time = 8;
            this._code = 0;
            this._prefixLimit = 0;
            this._goldBg.visible = false;
            this._coinBg.visible = false;
            this._maxPriceTxt.text = "0";
            this._maxPriceImg.bitmapData = null;
            return;
        }

        /* internal  */onSubmitBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var e: Object /* flash.events.MouseEvent */;
            var gold: int;
            var coin: int;
            var coinBind: int;
            var price: int;
            var seekBuyInfo: SeekBuyItemInfo;
            var onClickHandler: Function;
            var needCoin: int;
            var needCoins: int;

            var loc1;
            needCoin = 0;
            needCoins = 0;
            e = arg1;
            if (this._baseItem.itemData == null) 
            {
                MsgManager.showRollTipsMsg(Language.getString(31103));
                return;
            }
            if (this._unit == -1) 
            {
                MsgManager.showRollTipsMsg(Language.getString(31060));
                return;
            }
            if (this._unitPriceInput.text == "") 
            {
                MsgManager.showRollTipsMsg(Language.getString(31106));
                return;
            }
            if (parseInt(this._unitPriceInput.text) == 0) 
            {
                MsgManager.showRollTipsMsg(Language.getString(31107));
                return;
            }
            gold = Cache.instance.role.money.gold;
            coin = Cache.instance.role.money.coin;
            coinBind = Cache.instance.role.money.coinBind;
            price = parseInt(this._priceTxt.text);
            if (this._unit != EPrictUnit._EPriceUnitGold) 
            {
                if (this._unit == EPrictUnit._EPriceUnitCoin) 
                {
                    if (coin < price || coin + coinBind < price + this._rate) 
                    {
                        needCoins = price - coin;
                        Dispatcher.dispatchEvent(new DataEvent(EventName.ShopMallAutoBuyCoin, needCoins));
                        return;
                    }
                }
            }
            else 
            {
                if (gold < price) 
                {
                    onClickHandler = (arg1: int): void
                    {
                        if (arg1 == Alert.OK) 
                        {
                            Dispatcher.dispatchEvent(new DataEvent(EventName.GotoPay));
                            Alert.resetToDefault();
                        }
                        return;
                    }
                    Alert.show(Language.getString(30103), null, Alert.OK | Alert.CANCEL, null, onClickHandler);
                    return;
                }
                if (coin + coinBind < this._rate) 
                {
                    needCoin = this._rate - coin;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.ShopMallAutoBuyCoin, needCoin));
                    return;
                }
            }
            seekBuyInfo = new SeekBuyItemInfo();
            seekBuyInfo.code = this._code;
            seekBuyInfo.amount = this._numStepper.value;
            seekBuyInfo.prefixLimit = this._prefixLimit;
            seekBuyInfo.price = parseInt(this._unitPriceInput.text);
            seekBuyInfo.time = this._time;
            seekBuyInfo.unit = this._unit;
            seekBuyInfo.broadcast = this._broadcastCb.selected;
            Dispatcher.dispatchEvent(new DataEvent(EventName.MarketSeekBuyGoodsInfo, seekBuyInfo));
            return;
        }

        /* internal  */onSeekBuyItemCodeHandler(arg1: DataEvent): void
        {
            this._code = arg1.data as int;
            this._baseItem.itemData = new ItemData(this._code);
            this.searchMaxPrice();
            this.updatePrice();
            return;
        }

        /* internal  */searchMaxPrice(): void
        {
            var loc1=new ItemData(this._code);
            if (loc1.category != ECategory._ECategoryEquip) 
            {
                this._numStepper.maximum = 99;
            }
            else 
            {
                this._numStepper.maximum = 1;
            }
            var loc2=new Map<any, any> /* flash.utils.Dictionary */();
            loc2[this._code] = this._code;
            SearchConditionData.codesMap = loc2;
            SearchConditionData.career = 0;
            SearchConditionData.color = 0;
            SearchConditionData.levelLower = 1;
            SearchConditionData.levelUpper = 100;
            SearchConditionData.order = EMarketOrder._EMarketOrderDesc;
            SearchConditionData.recordType = EMarketRecordType._EMarketRecordTypeSeekBuy;
            SearchConditionData.targetPage = 1;
            Cache.instance.market.quickSearchType = 1;
            Dispatcher.dispatchEvent(new DataEvent(EventName.MarketSearch, null, true));
            return;
        }

        public updateMaxPrice(arg1: SSeqMarketItem): void
        {
            if (!arg1) 
            {
                this._maxPriceTxt.text = "0";
                this._maxPriceImg.bitmapData = null;
                return;
            }
            var loc1=arg1.marketItems[0];
            if (loc1) 
            {
                if (loc1.sellUnit != EPrictUnit._EPriceUnitCoin) 
                {
                    if (loc1.sellUnit == EPrictUnit._EPriceUnitGold) 
                    {
                        this._maxPriceTxt.text = loc1.sellPrice + "";
                        this._maxPriceImg.bitmapData = GlobalClass.getBitmapData(ImagesConst.Yuanbao_small);
                    }
                }
                else 
                {
                    this._maxPriceTxt.text = loc1.sellPrice + "";
                    this._maxPriceImg.bitmapData = GlobalClass.getBitmapData(ImagesConst.Tongqian_small);
                }
            }
            else 
            {
                this._maxPriceTxt.text = "0";
                this._maxPriceImg.bitmapData = null;
            }
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show();
            this.updateSeekBuyItem();
            return;
        }

        /* internal */ /* var */_typeComBo: GComboBox;

        /* internal */ /* var */_colorComBo: GComboBox;

        /* internal */ /* var */_careerComBo: GComboBox;

        /* internal */ /* var */_levelComBo: GComboBox;

        /* internal */ /* var */_allCodesArr: Array<any>;

        /* internal */ /* var */_maxPriceTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_nameTxtInput: GTextInput;

        /* internal */ /* var */_unitPriceInput: GTextInput;

        /* internal */ /* var */_moneySelect: MoneySelectPanel;

        /* internal */ /* var */_timeCombo: GComboBox;

        /* internal */ /* var */_itemArr: Array<any>;

        /* internal */ /* var */_numStepper: GNumericStepper;

        /* internal */ /* var */_priceTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_stringList: SearchStringList;

        /* internal */ /* var */_rateTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_coinBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_goldBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_maxPriceImg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_unit: int=-1;

        /* internal */ /* var */_time: int=8;

        /* internal */ /* var */_prefixLimit: int=0;

        /* internal */ /* var */_code: int=0;

        /* internal */ /* var */_rate: int=0;

        /* internal */ /* var */_careerMap: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_broadcastCb: GCheckBox;

        /* internal */ /* var */_baseItem: BaseItem;

        /* internal */ /* var */_selfCareer: int;

        /* internal */ /* var */_categoryComBo: GComboBox;
    }
